package com.niuxiaofa.newlaw.Tools;

import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;

/**
 * @ClassName SpannableString
 * @Description TODO
 * @Author Gxjkz
 * @Date 2020/9/14 13:47
 * @Version 1.0
 */
public class SpannableStringTools {


    public static SpannableString setSpannableString(String text,int start,int end){
        //设置Hello World前三个字符为红色,背景为蓝色
        SpannableString textSpanned1 = new SpannableString(text);
        textSpanned1.setSpan(new ForegroundColorSpan(Color.BLUE),
                start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        textSpanned1.setSpan(new BackgroundColorSpan(Color.BLUE),
//                0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return textSpanned1;

    }

    public static SpannableString setForegroundColorSpan(String text,int start,int end){
        //设置Hello World前三个字符为红色,背景为蓝色
        SpannableString textSpanned = new SpannableString(text);
        textSpanned.setSpan(new ForegroundColorSpan(Color.parseColor("#FF2883CF")),
                start, end,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//        textSpanned1.setSpan(new BackgroundColorSpan(Color.BLUE),
//                0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return textSpanned;

    }

}
